/*
 * 查询语句
 * */

package com.axt.dbaudit.bean.query;

import java.util.List;

import com.axt.dbaudit.base.MsgFuncExt;
import com.axt.dbaudit.base.QueryFilter;
import com.axt.dbaudit.base.QueryType;
import com.axt.dbaudit.model.query.Stmt;
import com.axt.dbaudit.model.query.StmtAlarm;
import com.axt.dbaudit.model.query.StmtDetail;

public class QueryStmtBean extends QueryBaseBean{
	public List<Stmt> getStmts() {
		try {
			return (List<Stmt>)getRecord();
		} catch (Exception e) {
			return null;
		}
	}
	
	public List<StmtDetail> getStmtDetails() {
		try {
			return (List<StmtDetail>)getRecord();
		} catch (Exception e) {
			return null;
		}
	}
	
	public List<StmtAlarm> getStmtAlarms() {
		try {
			return (List<StmtAlarm>)getRecord();
		} catch (Exception e) {
			return null;
		}
	}
	
	/* query Stmt indices */
	public int queryStmtIndices(
			String serverPath, List<QueryFilter> filters, int queryInResult, int maxRowNum) {
		
		init();
		setQueryType(QueryType.QUERY_T_STMT_IDX);
		setQueryInResult(queryInResult);
		setMaxRowNum(maxRowNum);
		setFilters(filters);
		
		return query(MsgFuncExt.FUNC_QUERY_QUERY_INDEX, serverPath);
	}
	
	/* query process maxRowNul = 0 */
	public int queryProcess(String serverPath, List<QueryFilter> filters) {
		
		init();
		setQueryType(QueryType.QUERY_T_STMT);
		setMaxRowNum(0);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_DATA, serverPath, 
				"com.axt.dbaudit.model.query.Stmt");
	}
	
	/* query Stmts */
	public int queryStmts(String serverPath, List<QueryFilter> filters) {
		
		init();
		setQueryType(QueryType.QUERY_T_STMT);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_DATA, serverPath, 
				"com.axt.dbaudit.model.query.Stmt");
	}
	
	/* stop query stmt indices */
	public int stopQueryIndices(String serverPath){
		
		init();
		setQueryType(QueryType.QUERY_T_STMT_IDX);
		
		return query(MsgFuncExt.FUNC_QUERY_STOP_LIST_IDX, serverPath);
	}
	
	/* query StmtDeatil */
	public int queryStmtDeatil(String serverPath, List<QueryFilter> filters){
		
		init();
		setQueryType(QueryType.QUERY_T_STMT_DETAIL);
		setQueryInResult(0);
		setMaxRowNum(1);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_NORMAL, serverPath, 
				"com.axt.dbaudit.model.query.StmtDetail");
	}
	
	/* query StmtAlarm */
	public int queryStmtAlarm(String serverPath, List<QueryFilter> filters){
		
		init();
		setQueryType(QueryType.QUERY_T_STMT_ALARM);
		setQueryInResult(0);
		setMaxRowNum(1);
		setFilters(filters);
		
		return query(
				MsgFuncExt.FUNC_QUERY_QUERY_NORMAL, serverPath, 
				"com.axt.dbaudit.model.query.StmtAlarm");
	}
}
